package com.qf.mvc2203.ex;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//@ControllerAdvice //代表当前类作为统一异常处理器
public class MyAnnotationExHandler {
    @ExceptionHandler(UserException.class)//代表当前方法要处理UserException
    public String userExHandler(UserException e) {
        System.out.println(e);
        return "/error/error02.html";
    }

    @ExceptionHandler(Exception.class)
    public String userExHandler(Exception e) {
        e.printStackTrace();//把异常的所有信息打印到控制台上
        return "/error/error01.html";
    }
}
